package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import com.sky.vo.OrderVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalTime;
import java.util.List;

@Mapper
public interface OrderMapper {
    /**
     * 向订单表中插入数据
     * @param order
     */
    void insert(Orders order);

    /**
     * 修改订单信息
     * @param orders
     */
    void update(Orders orders);

    /**
     * 根据订单号查询订单
     * @param orderNumber
     */
    @Select("select * from orders where number = #{orderNumber}")
    Orders getByNumber(String orderNumber);

    /**
     * 订单分页查询 用户端
     * @param ordersPageQueryDTO
     * @return
     */
    Page<Orders> pageQuery(OrdersPageQueryDTO ordersPageQueryDTO);

    /**
     * 根据id查询订单
     * @param id
     * @return
     */
    @Select("select * from orders where id = #{id}")
    OrderVO getOrderById(Long id);
    /**
     * 根据状态统计订单数量
     * @param
     */
    @Select("select count(id) from orders where status = #{status}")
    Integer countStatus(Integer toBeConfirmed);

    @Select("select * from orders where id = #{orderId}")
    Orders getById(Long orderId);

    @Select("select * from orders where status = #{pendingPayment} and order_time <= #{time}")
    List<Orders> getStatusAndOrderTime(Integer pendingPayment, LocalTime time);

    /**
     * 催单
     * @param id
     */
    @Select("select * from orders where id = #{id}")
    Orders reminder(Long id);
}
